<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <!-- 将 obejct 对象中属性是空字符串的替换为 null -->
</head>
<body>
  <script>
    let obj = {
      name: '张三',
      age: 30,
      sex: ''
    }
		console.log(obj,'修改之前的obj')
		let itemList = JSON.stringify(obj)
		let result = itemList.replace(/""/g, "null");
		obj = JSON.parse(result)
		console.log(obj,'修改之后的obj')
  </script>
</body>
</html>